package com.rp.system.dao;

import org.raptor.common.DbOperUtil;
import org.raptor.orm.hibernate.DbaHibernateTemplateSupport;
import org.raptor.pagination.Page2;
import org.springframework.stereotype.Repository;

import com.rp.common.vo.PageParam;
import com.rp.system.po.RpMessage;

@Repository
public class RpMessageDao extends DbaHibernateTemplateSupport<RpMessage> {

	/**
	 * 获取收件箱分页数据（弃用）
	 * @param userId
	 * @param pageParam
	 * @return
	 */
	@Deprecated
	public Page2 getInbox(String userId, PageParam pageParam){
		//String tt = "SELECT t FROM Teacher t join t.students s join s.books b where b.name = 'a' ";
		String hql = "select r from RpMessage r join r.receiver u where u.id = ?"
				+DbOperUtil.generateOrderBy("r.createDate", "desc");
		/*List ids = new ArrayList();
		ids.add("656f6d21-2d7d-41f4-96e5-04639516cb4b");
		ids.add("1a04957e-c1c2-4add-b649-80aafc3d9857");*/
		Page2 page = this.getPage2ByOffset(hql, 
				pageParam.getPageOffset(), pageParam.getPageSize(),
				pageParam.getSortField(), pageParam.getSortOrder(), userId);
		
		
		return page;
	}
	
	
}
